package store.lunangangster.bpmn.converter.parser;

import javax.xml.stream.XMLStreamReader;
import org.apache.commons.lang3.StringUtils;
import store.lunangangster.bpmn.model.BaseElement;
import store.lunangangster.bpmn.model.BpmnModel;
import store.lunangangster.bpmn.model.SequenceFlow;

public class ConditionExpressionParser extends BaseChildElementParser {

  @Override
  public String getTargetName() {
    return ELEMENT_CONDITION_EXPRESSION;
  }

  @Override
  public void parseChild(XMLStreamReader xsr, BaseElement parentElement, BpmnModel model)
      throws Exception {
    String conditionExpression = xsr.getElementText();
    if (StringUtils.isNotBlank(conditionExpression)) {
      ((SequenceFlow) parentElement).setConditionExpression(conditionExpression.trim());
    }
  }
}
